using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Game;
using UnityEngine;

namespace IQIGame.Onigao.GamePlay
{
    public class UIN_HeroFeatureOne : UIBaseNode
    {

        #region Template Generate,don't modify
        protected partial class UIB_UIN_HeroFeatureOne
        {
            #region ObjectBinding Generate 
            public IQIGame.Onigao.Framework.ExImage image { protected set; get; }
            public IQIGame.Onigao.Framework.ExText textTitle { protected set; get; }
            public IQIGame.Onigao.Framework.ExText textDesc { protected set; get; }
            public IQIGame.Onigao.Framework.ExText conditionText { protected set; get; }
            public GameObject star { protected set; get; }
            public virtual void InitBinding(ObjectBinding __binding)
            {
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExImage>("image", out var __tbv0);
                this.image = __tbv0;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExText>("textTitle", out var __tbv1);
                this.textTitle = __tbv1;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExText>("textDesc", out var __tbv2);
                this.textDesc = __tbv2;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExText>("conditionText", out var __tbv3);
                this.conditionText = __tbv3;
                __binding.TryGetVariableValue<UnityEngine.GameObject>("star", out var __tbv4);
                this.star = __tbv4;
            }


            #endregion ObjectBinding Generate 
        }
        #endregion Template Generate,don't modify

        #region fields & properties
        ListScrollAdapter<UIN_CommonDarkLight> _listStar = null;

        UD_HereFeature _hereFeature = null;

        protected UIB_UIN_HeroFeatureOne ui { get; set; }
        #endregion

        protected override void BeforeInit()
        {
            ui = new UIB_UIN_HeroFeatureOne();
            ui.InitBinding(this.csObjBind);
        }

        protected override void OnInit()
        {
            this._listStar = this.InitListScroll<UIN_CommonDarkLight>(this.ui.star, this.OnStarChanged);
        }

        public void Show(UD_HereFeature data)
        {
            this._hereFeature = data;
            if (this._hereFeature == null)
                return;
            this.Show();

            var cfgData = this._hereFeature.cfgStar;
            this.ui.textTitle.text = cfgData.SkillName;
            this.ui.textDesc.text = cfgData.SkillEffectText;
            bool _isUnlock = this._hereFeature.isUnlock;
            bool _isLock = !_isUnlock;
            this.ui.conditionText.SetActive(_isLock);
            if (_isLock)
            {
                this.ui.conditionText.text = APIUIHeroInfo.GetFeatureUnlockStr(this._hereFeature.nBigStarInCfg);
                this._listStar.RefillCells(this._hereFeature.nBigStarInCfg);
            }
            //this.ui.image.indexSwitchSprite = _isUnlock ? 1 : 0;
            //this.ui.textTitle.indexSwitchColor = _isUnlock ? 1 : 0;
            //this.ui.textDesc.indexSwitchColor = _isUnlock ? 1 : 0;
        }

        protected override void OnShow()
        {

        }

        protected override void OnHide()
        {

        }

        void OnStarChanged(UIN_CommonDarkLight item, int index)
        {
            item.Show(true);
        }

        protected override void OnDispose()
        {

        }
    }
}
